<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__STATIC__/admin/css/x-admin.css" media="all">
    </head>

    <body>
        <div class="x-body">
            <form class="layui-form" method="post">
                <input  name="id" value="{$data.id}" hidden>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>上级关系
                    </label>
                    <label for="username" class="layui-form-label">
                        {$data.gx}
                    </label>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>用户名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="username"  disabled required="" lay-verify="required" value="{$data.name}"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="lv" value="1" title="代理" {if condition="$data.lv eq 1"}checked{/if}>
                        <input type="radio" name="lv" value="2" title="会员" {if condition="$data.lv eq 2"}checked{/if}>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red"></span>密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_pass" name="pass" lay-verify="pass"
                        autocomplete="off" class="layui-input" >
                    </div>
                    <div class="layui-word-aux layui-form-mid">
                        <p>置空不修改</p>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red"></span>资金密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password"  name="money_pass"  lay-verify="money_pass"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-word-aux layui-form-mid">
                        <p>置空不修改</p>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red"></span>返点%
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  name="rebate"  lay-verify="money_pass"
                               autocomplete="off" class="layui-input" value="{$data.rebate}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <p>可用分佣为百分之{$data.minfy}-{$data.maxfy}</p>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red"></span>可用余额
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_repass" name="money" required="" lay-verify="money_pass"
                               autocomplete="off" class="layui-input" value="{$data.money}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="state" value="1" title="正常" {if condition="$data.state eq 1"}checked{/if}>
                        <input type="radio" name="state" value="2" title="冻结" {if condition="$data.state eq 2"}checked{/if}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red"></span>备注
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  name="remark"  lay-verify="money_pass"
                               autocomplete="off" class="layui-input" value="{$data.remark}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="save" lay-submit="">
                        保存
                    </button>
                </div>
            </form>
        </div>
        <script src="__STATIC__/admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="__STATIC__/admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;

              //自定义验证规则
              form.verify({
                ypass: [/(.+){5,12}$/, '密码必须5到12位']
                ,xpass: [/(.+){5,12}$/, '密码必须5到12位']
              });

            form.on('submit(save)', function(data){
                var name = $('#username').val();
                var ypass = $('#L_pass').val();
                var xpass = $('#L_repass').val();
                $.ajax({
                    url:"{:url('User/userEdit')}",
                    data:data.field,
                    type:'post',
                    dataType:'json',
                    success:function (data) {
                        data = JSON.parse(data);
                        if(data.msg == 1){
                            layer.alert(data.data, {icon: 6},function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                            });
                        }else{
                            layer.alert(data.data,{icon: 5});
                        }
                    },
                    error:function () {
                        layer.alert("服务器出现错误",{icon: 5});
                    }
                })
                return false;
            });


            });
        </script>
        <script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
        </script>
    </body>

</html>